package com.lensyn.aspect;


import java.util.Iterator;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LogAspect {
	@Pointcut("@annotation(com.lensyn.annotation.Log)")
	private void cut() { }    
	@Around("cut()")
	public void advice(ProceedingJoinPoint joinPoint){
	    System.out.println("环绕通知之开始");
	    try {
//	        joinPoint.proceed();
	        Object retval=  joinPoint.proceed();
	        if(retval instanceof String){
	        	System.out.println(retval+"=============retval");
	        }
	    } catch (Throwable e) {
	        e.printStackTrace();
	    }
	    Object[] args = joinPoint.getArgs();
	    for (Object object : args) {
			if(object instanceof String){
				System.out.println(object+"----String");
			}
			if(object instanceof Integer){
				System.out.println(object+"----int");
			}
		}
	 
	    System.out.println("环绕通知之结束");
	}
}